package com.fastloan.mgt.product.postloan.controller;

import com.fastloan.mgt.log.aspect.SystemLog;
import com.fastloan.mgt.product.postloan.model.ProductPostLoan;
import com.fastloan.mgt.product.postloan.service.ProductPostLoanService;
import com.kawins.base.baseabs.BaseController;
import com.kawins.result.ResultEnum;
import com.kawins.result.ResultTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author chenkai
 *         createTime 2017-11-2017/11/10 10:50
 */
@RestController
@RequestMapping("/api/web/productPostLoan")
public class ProductPostLoanController extends BaseController<ProductPostLoan> {
    @Autowired
    private ProductPostLoanService productPostLoanService;

    /**
     * 获取贷后详情
     * @param productId
     * @return
     */
    @GetMapping("/{productId}")
    public ResultTo getPostLoan(@PathVariable String productId) {
        return new ResultTo().setData(productPostLoanService.queryProductPostLoan(productId));
    }

    /**
     * 更新贷后信息
     * @param postLoan
     * @return
     */
    @PostMapping
    @SystemLog(description="更新贷后信息")
    public ResultTo putPostLoan(ProductPostLoan postLoan) {
        return productPostLoanService.pagePostLoan(postLoan) != null ? new ResultTo() : new ResultTo(ResultEnum.OPERATION_FAILED);
    }
}
